package com.example;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@SpringBootApplication
@RestController
public class ApplicationDemo {

    @RequestMapping("/")
    public String home(HttpServletRequest request) {
        String ipAddress = request.getRemoteAddr();
        String requestURI = request.getRequestURI();
        String method = request.getMethod();
        String info = ipAddress +"\n"+ requestURI +"\n" + method;
        // 打印请求信息
        System.out.println("IP Address: " + ipAddress);
        System.out.println("Request URI: " + requestURI);
        System.out.println("Method: " + method);

        return info;
    }
    public static void main(String[] args) {
        SpringApplication.run(ApplicationDemo.class,args);
    }
}